<?php 
	//ini_set('display_errors', false);
	//error_reporting(0);
?>
<div class="clear_both"></div>
<div class="main_container">
<div class="div_block">Payroll Period: 
	<select id="period" name="period">
	<option value="">-- Select --</option>
	<?php foreach($periods as $p):?>
		<option value="<?php echo $p->id?>"><?php echo DateUtils::formatDate($p->date_start, ConstantsUtils::$DATE_FRIENDLY_FORMAT). " to " .DateUtils::formatDate($p->date_end, ConstantsUtils::$DATE_FRIENDLY_FORMAT) ;?></option>
	<?php endforeach;?>
	</select>
</div>
<?php if(isset($payroll_period_id) && $payroll_period_id  > 0):?>
<div class="display_summary">
<table>
	<tr><td width="25%" class="rest_day"># Pending: <?php echo isset($pending) && $pending > 0?"<a href='#'>{$pending}</a>":0;?></td><td width="25%" class="text_green"># Confirmed: <?php echo isset($confirmed) && $confirmed > 0?"<a href='#'>{$confirmed}</a>":0;?></td> <td width="25%" class="text_green"># Submitted: <?php echo isset($submitted) && $submitted > 0?"<a href='#'>".$submitted."</a>":0;?></td></tr>
</table>
</div>
<?php endif;?>

<?php if(isset($timesheet)):?>
<table border="1" cellspacing="0" cellpadding="5" id="members" class="display">
<thead>
	<th>Employee Name</th>
	<th>Reg Hours</th>
	<th>Reg OT</th>
	<th>Reg ND</th>
	<th>Restday</th>
	<th>Excess RD</th>
	<th>Restday ND</th>
	<th>Special</th>
	<th>Excess SH</th>
	<th>Special ND</th>
	<th>Special RD</th>
	<th>Excess SR</th>
	<th>Others</th>
	<th>Earnings</th>
	<th>Action</th>
</thead>
<?php foreach($timesheet as $ts) {
	
	$others = $ts->legal_holiday + $ts->excess_legal_holiday + $ts->legal_holiday_restday + $ts->excess_legal_holiday_restday + $ts->legal_holiday_night_differential
	
	
	
	
	
?>
<tr class="timesheet_details" ts_id="<?php echo $ts->user_id;?>">
	<td><?php echo $ts->first_name?></td>
	<td><?php echo $ts->regular_hours?></td>
	<td><?php echo $ts->regular_overtime?></td>
	<td><?php echo $ts->regular_night_differential?></td>
	<td><?php echo $ts->restday?></td>
	<td><?php echo $ts->excess_restday?></td>
	<td><?php echo $ts->restday_night_differential?></td>
	<td><?php echo $ts->special_holiday?></td>
	<td><?php echo $ts->excess_special_holiday?></td>
	<td><?php echo $ts->special_holiday_night_differential?></td>
	<td><?php echo $ts->special_holiday_restday?></td>
	<td><?php echo $ts->excess_special_holiday_restday?></td>
	<td><?php echo $others?></td>
	<td><?php echo number_format(floatval($ts->earnings), 2, '.', '') ;?></td>
	<td><a href="<?php echo base_url()?>payroll/view_user/<?php echo $payroll_period_id?>/<?php echo $ts->user_id?>">View</a></td>
</tr>
<?php }?>
</table>
<?php endif;?>
</div>
<script language="javascript">
var path = "<?php echo base_url()?>timesheet/view_user/" + "<?php echo $payroll_period_id?>" + '/';
$(document).ready(function() {
	$('#members').dataTable({
		"sPaginationType": "full_numbers",
		"iDisplayLength":50
	});

	$('select#period').val("<?php echo $payroll_period_id?>");

	$("#period").change(function(){
		var url = "<?php echo base_url()?>payroll/index/" + parseInt($(this).val());
		document.location = url;
	})
	
} );
</script>
